package com.irs.irsforum.web;


import com.irs.irsforum.entity.Subject;
import com.irs.irsforum.security.access.Access;
import com.irs.irsforum.security.access.UserType;
import com.irs.irsforum.service.ISubjectService;
import com.irs.irsforum.web.common.BaseController;
import com.irs.irsforum.web.common.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yihuili
 * @since 2020-01-18
 */
@RestController
@RequestMapping("/subject")
public class SubjectController extends BaseController {
    private static final Logger logger =
            LoggerFactory.getLogger(SubjectController.class);

    @Autowired
    ISubjectService subjectService;

    /**
     * 发帖时显示subject列表
     * @return
     */
    @Access(userType = {UserType.LOGIN_USER})
    @RequestMapping(value = "/showsubject", method = RequestMethod.GET)
    public Object showSubject() {
        logger.info("显示subject列表");
        List<Subject> subjectList = subjectService.getSubjectList();
        return ResponseResult.newSuccessResult(subjectList);
    }
}

